package com.zhl.main;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

import com.zhl.service.FavoriteService;
@Service
public class app {
	
	@Autowired
	FavoriteService favorite;
	
	public void setFavorite(FavoriteService favorite){
		this.favorite = favorite;
 	}
	

	public static void main(String[] args){
		long aa=System.currentTimeMillis();
		@SuppressWarnings("resource")
		//加载配置文件耗时将近一秒
		ApplicationContext context2 = new ClassPathXmlApplicationContext("ApplicationContext.xml"); 
		long bb=System.currentTimeMillis();
		
		//方法1：明显慢一点，差不多0.06秒
		app qqq = (app) context2.getBean("app");
		qqq.favorite.findAll();
		
		long cc=System.currentTimeMillis();
		
		//方法2：明显快一些，差不多0.01秒，相差大概6-7倍的速度
		FavoriteService a = (FavoriteService) context2.getBean("favoriteService");
		a.findAll();
		long dd=System.currentTimeMillis();
		
		System.out.println("运行时间："+(bb-aa)/1000f+"\t"+(cc-bb)/1000f+"\t"+(dd-cc)/1000f);
	}
}
